package cn.lhl.core.demo.emoji.filter.controller;

import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

/**
 * description
 *
 * @author liuhongliang
 * @version 2021/9/23
 */

@Slf4j
@RequestMapping("/v1/api/demo")
@RestController
public class DemoController {


  /**
   * cmt
   */
  @PostMapping("/saveOperation")
  public void saveOperation(@RequestBody OperationQO operationQO) {
    String desc = operationQO.getDescription();
    log.info("saveOperation desc={}", desc);
  }

  /**
   * cmt
   */
  @PostMapping("/saveOperationForm")
  public void saveOperationForm(OperationQO operationQO) {
    String desc = operationQO.getDescription();
    log.info("saveOperation desc={}", desc);
    RequestAttributes requestAttributes = RequestContextHolder.currentRequestAttributes();
    HttpServletRequest request = ((ServletRequestAttributes) requestAttributes).getRequest();
    String paramField = "description";
    String p1 = request.getParameter(paramField);
    String[] parameterValues = request.getParameterValues(paramField);
    Map<String, String[]> parameterMap = request.getParameterMap();
    System.out.println(1);
  }

  @Data
  public static class OperationQO {
    private String description;
  }
}
